package com.cloud.neo4j.business.neo4j.car.repository;

import com.cloud.neo4j.business.neo4j.car.entity.PersonRelationShipEntity;
import org.neo4j.driver.Result;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Optional;

/**
 * 测试持久层
 * @date 2022-05-24
 * @author 刘房
 */
@Resource
public interface PersonRelationShipRepository extends Neo4jRepository<PersonRelationShipEntity, Long> {

    /**
     * 查询与Tom Hanks参演电影两次及以上的演员名单
     * @param name  查询人 Tom Hanks
     * @param type  类型关系
     * @param number    次数
     * @return  PersonRelationShipEntity
     */
    @Query("MATCH (p:Person{name:\"Tom Hanks\"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(pw:Person) with p,pw,count(pw) as number where number >1  RETURN pw,p,number")
    Result findActenInPersonGtNumberByNameAndTypeAndNumber(String name, String type, Integer number);
}
